-
Couldn't load subscription status.
- Fork 793
[SYCL][clang-linker-wrapper] Fix argument parsing in Clang Linker Wrapper #20470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sycl
Are you sure you want to change the base?
Conversation
… new offloading model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E2E tests LGTM
clang/lib/Driver/Driver.cpp
Outdated
| /// Otherwise return 'false'. | ||
| bool Driver::GetUseNewOffloadDriverForSYCLOffload(Compilation &C, | ||
| const ArgList &Args) const { | ||
| // Check only if enabled with -fsycl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Check only if enabled with -fsycl | |
| // Check only if enabled with -fsycl. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestions! The changes for enabling the new offloading model in this PR were copied directly from another PR (#15121). This PR specifically focuses on resolving test failures in fp64-conv-emu-1.cpp and fp64-conv-emu-2.cpp that occur after enabling the new offloading model. I will move any comments related to the new offloading model changes to the original PR where that functionality was implemented. The changes related to enabling the new offloading model have been reverted and removed from this PR.
clang/lib/Driver/Driver.cpp
Outdated
| /// Utility function to parse all devices passed via -fsycl-targets. | ||
| /// Return 'true' for JIT, AOT Intel CPU/GPUs and NVidia/AMD targets. | ||
| /// Otherwise return 'false'. | ||
| bool Driver::GetUseNewOffloadDriverForSYCLOffload(Compilation &C, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name doesn't describe very well what the function is doing, or at least doesn't align very well with the description in the comment above. I would expect something including the words Get and Devices at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to the previous comment as well :)
| if (!BeforeOptions.empty()){ | ||
| SmallVector<StringRef, 8> BeforeArgs; | ||
| BeforeOptions.split(BeforeArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false); | ||
| for (auto string : BeforeArgs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is most likely introducing a copy for each arg. Can we try const auto & instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestions! I have made the change.
| CmdArgs.push_back(Args.MakeArgString(Replace)); | ||
| SmallVector<StringRef, 8> AfterArgs; | ||
| AfterOptions.split(AfterArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false); | ||
| std::string JoinedOptions = llvm::join(AfterArgs, " "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this pass all tests? It was similar to this before and I had to add the , because it was causing trouble with ocloc. I added a specific test for that, so if it is passing, then I'm good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests that were previously failing for the clang-linker-wrapper issue (fp64-conv-emu-1.cpp and fp64-conv-emu-2.cpp) are now passing. The tests currently failing in CI (such as https://github.com/intel/llvm/actions/runs/18854382403/job/53800150157) for the new offloading model are unrelated to this issue and will be addressed in future PRs. I am wondering which one is the test you mentioned adding for this issue? I'm not sure if you're referring to https://github.com/intel/llvm/blob/sycl/sycl/test-e2e/SYCLBIN/simple_kernel_aot; this test is passing with the current changes.
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu %O0 %s -o %t.out | ||
| // RUN: %{run} %t.out | ||
|
|
||
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --offload-new-driver %O0 %s -o %t.out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also try with -g? The code you're changing used to have issues with -g, so just to be on the safe side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes work with '-g' and I have also added a new test command in this file for running the test with -g. Thank you!
clang/lib/Driver/Driver.cpp
Outdated
| options::OPT_offload_new_driver, false)) | ||
| return false; | ||
|
|
||
| if (Args.hasArg(options::OPT_fintelfpga)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support for FPGA related options have been removed in this PR.
Don't think this check is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestions! The changes for enabling the new offloading model in this PR were copied directly from another PR (#15121). This PR specifically focuses on resolving test failures in fp64-conv-emu-1.cpp and fp64-conv-emu-2.cpp that occur after enabling the new offloading model. I will move any comments related to the new offloading model changes to the original PR where that functionality was implemented. The changes related to enabling the new offloading model have been reverted and removed from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but will fall back to marcos for the in-depth review
| if (q.get_device().has(aspect::fp64)) | ||
| nfail += test<Increment<double>>(q); | ||
| // This test is currently disabled because it requires the -ze-fp64-gen-emu | ||
| // IGC option to run FP64 arithmetic operations. The -fsycl-fp64-conv-emu flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry why are we seeing this failure now?
| if (!BeforeOptions.empty()) | ||
| CmdArgs.push_back(BeforeOptions); | ||
| if (!BeforeOptions.empty()) { | ||
| SmallVector<StringRef, 8> BeforeArgs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also just wondering, i see one of your commits is titled says 'revert nick's PR' but i don't remember writing that code so if it is referring to me do you mind linking the PR being reverted, thanks
This patch resolves failures in SYCL E2E tests
fp64-conv-emu-1.cppandfp64-conv-emu-2.cppwhen using the new offloading model by addressing two issues:(1) The original implementation in the
ClangLinkerWrapper.cppincorrectly constructedocloccommand line arguments by concatenating all arguments into a single string; this caused parsing failures in the executor. This is fixed in this patch by splitting arguments on whitespace boundaries and rejoining them into a correctly formatted command string.(2) The double-precision variable test case in fp64-conv-emu-2.cpp has been temporarily disabled because the current implementation only supports
-fsycl-fp64-conv-emu, which provides limited FP64 emulation for kernels containing FP64 conversions but no FP64 computations. The test will be re-enabled once-fsycl-fp64-gen-emu(full FP64 emulation) is implemented.